package com.artisan.common.utils.wxpay;


import java.security.MessageDigest;

public class WXPMD5 {

	public WXPMD5() {}
	
	public final static   String getMessageDigest(byte[] buffer) {
		char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
		try {
			MessageDigest mdTemp = MessageDigest.getInstance("MD5");
			mdTemp.update(buffer);
			byte[] md = mdTemp.digest();
			int j = md.length;
			char str[] = new char[j * 2];
			int k = 0;
			for (int i = 0; i < j; i++) {
				byte byte0 = md[i];
				str[k++] = hexDigits[byte0 >>> 4 & 0xf];
				str[k++] = hexDigits[byte0 & 0xf];
			}
			String res = new String(str);
			return res;
		} catch (Exception e) {
			return null;
		}
	}

	public static void main(String[] args) {
		try {

			String temp = "appid=wxf2cbc8b880a2012b&body=领泊车位支付&mch_id=1339413701&nonce_str=43TO89&notify_url=http://www.telesing.com&out_trade_no=0510105532-8888&spbill_create_ip=123.57.153.142&total_fee=1&trade_type=APP&key=5652c358c478e3ee4bd9938e02b5a9f7";
			System.out.print(new WXPMD5().getMessageDigest(temp.getBytes("UTF-8")).toUpperCase());
		}catch (Exception e){

		}





	}
}
